home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2305 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  93 lines

  1. Path: oasis.novia.net!not-for-mail
  2. From: tsyslo@oasis.novia.net (Tony Syslo)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: C compiler problem
  5. Date: 30 Jan 1996 03:29:37 GMT
  6. Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
  7. Message-ID: <4ek3b2$a5k@nntp.novia.net>
  8. NNTP-Posting-Host: oasis.novia.net
  9. X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
  10.  
  11. I have a friend who is converting a CNET BBS game from ARREX to C.
  12. Here is his request:
  13.  
  14. Can anyone tell me why this program is not compiling?
  15. I am using SAS/C 6.50, and am getting a BPTR error on line 35 with the
  16. "struct FileHandle *".
  17.  
  18. PROGRAM START:
  19.  
  20. /* File Open */
  21.  
  22. #include <clib/dos_protos.h>
  23. #include <dos/dos.h>
  24. #include <stdio.h>
  25. #include <exec/types.h>
  26.  
  27. int main();
  28.  
  29.   char name[80];
  30.   int age;
  31.  
  32. int main()
  33.  
  34. {
  35.   struct FileHandle *file_handle;
  36.   long bytes_written;
  37.   long bytes_read;
  38.  
  39.  printf("Enter your name: ");
  40.  scanf("%s",name);
  41.  printf("\nEnter your age: ");
  42.  scanf("%d",&age);
  43.  
  44.  
  45.   file_handle=(struct FileHandle *)
  46.     Open("RAM:You.dat",MODE_NEWFILE);
  47.   /* Have we opened the file successfully? */
  48.   if(file_handle==NULL)
  49.   {
  50.     printf("Could not open the file!\n");
  51.     Exit(0);
  52.   }
  53.   /* We have now opened a file, and are ready to start writing: */
  54.   bytes_written=Write(file_handle,name,sizeof(name));
  55.   bytes_written=bytes_written+Write(file_handle,age,sizeof(age));
  56.   if(bytes_written!=sizeof(name)+sizeof(age))
  57.   {
  58.     printf("Could not save the list!\n");
  59.     Close(file_handle);
  60.     Exit(0);
  61.   }
  62.   else
  63.     printf("Saved successfully!\n");
  64.   printf("Memory cleared!\n");
  65.    name="";
  66.    age=0;
  67.   printf("Loading!\n");
  68.   Seek(file_handle,0,OFFSET_BEGINNING);
  69.   bytes_read=Read(file_handle,name,sizeof(name));
  70.   bytes_read=bytes_read+Read(file_handle,age,sizeof(age));
  71.   if(bytes_read!=sizeof(name)+sizeof(age))
  72.   {
  73.     printf("Could not read the list!\n");
  74.     Close(file_handle);
  75.     Exit(0);
  76.   }
  77.   /* Print out the data: */
  78.     printf("Hello, %s!\",name);
  79.     printf("You are %d years old!\n",age);
  80.   /* Close the file: */
  81.   Close(file_handle);
  82. }
  83.  
  84. PROGRAM END:
  85.  
  86. Also, are there any good random number generators I could use? I am in need
  87. of a script, or something, that is fast, for a game I am writing, or
  88. converting, rather... Anything will work, even if it is a psuedo-random
  89. generator.
  90.  
  91. Thanx for any and all help!
  92.  
  93.